package com.ruoyi.cms.controller.portal;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cms.entity.domain.ModelCollection;
import com.ruoyi.cms.entity.req.ModelCollectionListReq;
import com.ruoyi.cms.entity.resp.ModelCollectionListResp;
import com.ruoyi.common.annotation.AllowAnonymous;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.cms.service.ModelCollectionService;

import java.util.List;

/**
 * 模型合集
 */
@RestController
@RequestMapping("/portal/cms/collection")
public class ModelCollectionController {

    @Autowired
    private ModelCollectionService modelCollectionService;

    /**
     * 查询模型合集列表（允许未登录）
     */
    @PostMapping("/list")
    @AllowAnonymous
    public R<Page<ModelCollectionListResp>> list(@RequestBody ModelCollectionListReq req) {
        return modelCollectionService.list(req);
    }

    /**
     * 查询我的合集列表
     */
    @PostMapping("/myCollectionList")
    public R<Page<ModelCollectionListResp>> myCollectionList(@RequestBody ModelCollectionListReq req) {
        return modelCollectionService.myCollectionList(req);
    }

    /**
     * 新增模型合集
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody ModelCollection modelCollection) {
        return modelCollectionService.add(modelCollection);
    }

    /**
     * 删除模型合集
     */
    @PostMapping("/delete")
    public R<?> delete(@RequestParam List<String> ids) {
        return modelCollectionService.delete(ids);
    }

    /**
     * 修改模型合集
     */
    @PostMapping("/update")
    public R<?> update(@RequestBody ModelCollection modelCollection) {
        return modelCollectionService.update(modelCollection);
    }

}
